As a rotary encoder for detecting an absolute angular position of a rotating body, a magnetic rotary encoder is known, in which a magnet is attached to a rotating body, a magnetic field generated by the magnet is detected by a magnetosensitive element (magnetic sensor) provided close to the rotating body, and a rotation angle is determined based on the fact that the intensity of a detected magnetic field changes in accordance with a rotation angle of a rotating body. As an example, a magnet with an N pole and an S pole magnetized in a circumferential direction is disposed on an end face of a rotation axis of a rotating body, and a magnetosensitive element having an output proportional to the magnitude of the magnetic field by this magnet is arranged on the extension of the rotation axis in a fixed body. As a magnetosensitive element, one capable of detecting the intensity of the magnetic field at two positions shifted by 45° from each other with respect to the rotation of the rotary shaft is used. Alternatively, in the case of using an element, like a Hall element, capable of detecting the intensity of the magnetic field including the direction of the magnetic field, a magnetosensitive element is disposed at a position shifted by 90° from each other with respect to the rotation of a rotation axis. Then, the magnetosensitive element provides outputs that change with a sine function (sin) and a cosine function (cos) against the rotation angle of the rotating body, and the rotation angle, that is, the absolute angular position of the rotating body can be obtained by calculating an angular position by arctangent (tan−1 or arctan) operation for the ratio of these outputs.
In order to increase the resolution of rotation angle detection in such a magnetic rotary encoder, Patent Document 1 discloses that when the magnet and the magnetosensitive element in the above configuration are provided respectively as a first magnet and a first magnetosensitive element, a second magnet disposed annularly around the rotation axis is provided on the rotating body, and a second magnetosensitive element for detecting the magnitude of the magnetic field generated by the second magnet is provided on the fixed body. In the second magnet, a plurality of pairs of N poles and S poles are magnetized alternately along the circumferential direction of the rotor. In other words, the plurality of N poles and the same number of S poles are alternately arranged in the circumferential direction of the rotor. The second magnetosensitive element is configured to be able to detect a magnitude of magnetization in each of positions spaced apart by a distance corresponding to a quarter of the circumferential length of a single pole of N pole or S pole, that is, a magnitude of a magnetic field due to the magnetization of the second magnet (in the case where it is possible to detect the intensity including the direction of the magnetic field, like the Hall element, a detection position interval is assumed to be half of the circumferential length of a single pole of N pole or S pole). In this configuration, when the rotating body rotates by an angle corresponding to the circumferential length of a single pole of N pole or S pole, the second magnetosensitive element outputs sine and cosine outputs similar to the sine and cosine outputs from the first magnetosensitive element when the rotor rotates once. Therefore, arctangent calculation is performed based on the output of the first magnetosensitive element to find which N pole or S pole of the second magnet the current rotation angle corresponds to, and then by performing arctangent calculation based on the output of the second magnetosensitive element, it is possible to detect a rotation angle with improved resolution according to the number of pairs of N pole and S pole in the second magnet. Further, in Patent Document 1, a plurality of pairs of N poles and S poles magnetized alternately along the circumferential direction of the rotor are used as a track, and a plurality of tracks are arranged in parallel in the radial direction of the rotor. In addition, it is disclosed that the detection accuracy of the angle of the rotating body is improved by configuring so that only the S pole of the other track is in contact with the N pole of one track between adjacent tracks. Assuming that there are two rows of tracks, this configuration can be said that the second magnet has a pair of N poles and S poles arranged in the radial direction of the rotor as a pole pair, and a plurality of pole pairs are annularly arranged so that the orientations of the N pole and S pole are opposite to each other between adjacent pole pairs.